# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=dlfcn
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2.0
pkgrel=1
pkgdesc="A wrapper for dlfcn to the Win32 API (mingw-w64)"
arch=('any')
url="https://github.com/dlfcn-win32/dlfcn-win32"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' 'staticlibs')
source=(${_realname}-${pkgver}.tar.gz::https://github.com/dlfcn-win32/dlfcn-win32/archive/v${pkgver}.tar.gz
        unify-makefile.patch)
sha256sums=('f18a412e84d8b701e61a78252411fe8c72587f52417c1ef21ca93604de1b9c55'
            'e1668cf99f3e41b51be6ff75f48350d761f19d501f7c70a5322b72b7e746bfea')

prepare() {
  cd "${srcdir}/dlfcn-win32-${pkgver}"
#  patch -p1 -i "${srcdir}"/unify-makefile.patch
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -rf "$srcdir/dlfcn-win32-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --libdir=${MINGW_PREFIX}/lib \
    --incdir=${MINGW_PREFIX}/include \
    --disable-stripping \
    --enable-shared \
    --disable-msvc

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
